<?php

	/**
	 * @see Zend_View_Helper_Abstract
	 */
	require_once 'Zend/View/Helper/Abstract.php';
	
	/**
	 * @see Zend_View_Helper_ServerUrl
	 */
	require_once 'Zend/View/Helper/ServerUrl.php';
	
	
	class Bike_View_Helper_FilePath extends Zend_View_Helper_Abstract
	{
	    public function filePath($Path, $Type=Null)
	    {
	    	if(strstr($Path, '://'))
	    	{
	    		$path = $Path;
	    	}
	    	else
	    	{
	    		$serverUrl = new Zend_View_Helper_ServerUrl();
	    		$path = $serverUrl->serverUrl();
	    		if(substr($Path, 0, 1) == '/')
	    		{
	    			$path .= $Path;
	    		}
	    		else
	    		{
	    			$path .= $this->getPath($Type).$Path;
	    		}
	    	}
	    	
	    	return $path;
	    }
	    
	    protected function getPath($Type)
	    {
	    	if($Type)
	    	{	    		
		    	$paramName = strtolower($Type).'Path';
		    	$value = Zend_Controller_Front::getInstance()->getParam($paramName);
		    	if(!$value)
		    	{
		    		require_once 'Zend/View/Exception.php';
		    		throw new Zend_View_Exception('Undefined param "'.$paramName.'" at front controller');
		    	}	    	
	    		return $value;
	    	}
	    }
	    
	    
	}
